<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function Bag(brand,size){
            this.brand=brand;
            this.size=size;
            this.flag=false;
            this.zip=function(){
                console.log("拉开拉链");
                this.flag=true;
                return this;
            };
            this.zipOut=function(){
                console.log("拉上拉链");
                this.flag=false;
                return this;
            }
            this.push=function(){
                if(this.flag){
                    console.log("放入东西");
                }else{
                    console.log("请先拉开拉链!");
                }
                return this;
            }
        }
        var bag=new Bag("书包",50);
        bag.push().zip().push().zipOut();
    </script>
</body>
</html>